﻿using HML.Design;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;

namespace HML
{
    /// <summary>
    /// ImageSlide图例栏
    /// </summary>
    [TypeConverter(typeof(PropertyOrderConverter))]
    public class ImageSlideLegendsBar
    {
        #region 属性

        private bool visible = true;
        /// <summary>
        ///是否显示图例栏
        /// </summary>
        [Description("是否显示图例栏")]
        [PropertyOrder(-200)]
        [DefaultValue(true)]
        public bool Visible
        {
            get { return this.visible; }
            set
            {
                if (this.visible == value)
                    return;

                this.visible = value;
                this.Invalidate();
            }
        }

        private int size = 12;
        /// <summary>
        ///图例Size
        /// </summary>
        [Description("图例Size")]
        [PropertyOrder(-198)]
        [DefaultValue(12)]
        public int Size
        {
            get { return this.size; }
            set
            {
                if (this.size == value || value <= 0)
                    return;

                this.size = value;
                if (this.Visible)
                {
                    this.Invalidate();
                }
            }
        }

        private Color borderColor = Color.FromArgb(180, 128, 128, 128);
        /// <summary>
        /// 图例边框颜色
        /// </summary>
        [Description("图例边框颜色")]
        [PropertyOrder(-197)]
        [DefaultValue(typeof(Color), "180, 128, 128, 128")]
        [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
        public Color BorderColor
        {
            get { return this.borderColor; }
            set
            {
                if (this.borderColor == value)
                    return;

                this.borderColor = value;
                if (this.Visible)
                {
                    this.Invalidate();
                }
            }
        }

        private Color backNormalColor = Color.FromArgb(10, 128, 128, 128);
        /// <summary>
        ///图例背景颜色（正常）
        /// </summary>
        [Description("图例背景颜色（正常）")]
        [PropertyOrder(-194)]
        [DefaultValue(typeof(Color), "10, 128, 128, 128")]
        [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
        public Color BackNormalColor
        {
            get { return this.backNormalColor; }
            set
            {
                if (this.backNormalColor == value)
                    return;

                this.backNormalColor = value;
                if (this.Visible)
                {
                    this.Invalidate();
                }
            }
        }

        private Color backIndexColor = Color.FromArgb(100, 128, 128, 128);
        /// <summary>
        ///图例背景颜色（当前索引）
        /// </summary>
        [Description("图例背景颜色（当前索引）")]
        [PropertyOrder(-192)]
        [DefaultValue(typeof(Color), "100, 128, 128, 128")]
        [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
        public Color BackIndexColor
        {
            get { return this.backIndexColor; }
            set
            {
                if (this.backIndexColor == value)
                    return;

                this.backIndexColor = value;
                if (this.Visible)
                {
                    this.Invalidate();
                }
            }
        }

        #endregion

        #region 字段

        private ImageSlide owner = null;

        #endregion

        public ImageSlideLegendsBar(ImageSlide owner)
        {
            this.owner = owner;
        }

        #region 私有方法

        /// <summary>
        /// 刷新控件
        /// </summary>
        private void Invalidate()
        {
            if (this.owner != null)
            {
                this.owner.Invalidate();
            }
        }

        #endregion
    }

}
